package com.ruoyi.web.controller.books;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.books.domain.BooksTheatreBusiness;
import com.ruoyi.books.service.IBooksTheatreBusinessService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 非遗戏剧行当汇总Controller
 *
 * @author ruoyi
 * @date 2024-03-30
 */
@Anonymous
@RestController
@RequestMapping("/books/business")
public class BooksTheatreBusinessController extends BaseController
{
    @Autowired
    private IBooksTheatreBusinessService booksTheatreBusinessService;

    /**
     * 查询非遗戏剧行当汇总列表
     */
//    @PreAuthorize("@ss.hasPermi('books:business:list')")
    @GetMapping("/list")
    public TableDataInfo list(BooksTheatreBusiness booksTheatreBusiness)
    {
        startPage();
        List<BooksTheatreBusiness> list = booksTheatreBusinessService.selectBooksTheatreBusinessList(booksTheatreBusiness);
        return getDataTable(list);
    }

    /**
     * 导出非遗戏剧行当汇总列表
     */
//    @PreAuthorize("@ss.hasPermi('books:business:export')")
    @Log(title = "非遗戏剧行当汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BooksTheatreBusiness booksTheatreBusiness)
    {
        List<BooksTheatreBusiness> list = booksTheatreBusinessService.selectBooksTheatreBusinessList(booksTheatreBusiness);
        ExcelUtil<BooksTheatreBusiness> util = new ExcelUtil<BooksTheatreBusiness>(BooksTheatreBusiness.class);
        util.exportExcel(response, list, "非遗戏剧行当汇总数据");
    }

    /**
     * 获取非遗戏剧行当汇总详细信息
     */
//    @PreAuthorize("@ss.hasPermi('books:business:query')")
    @GetMapping(value = "/{theatreBusinessId}")
    public AjaxResult getInfo(@PathVariable("theatreBusinessId") Long theatreBusinessId)
    {
        return success(booksTheatreBusinessService.selectBooksTheatreBusinessByTheatreBusinessId(theatreBusinessId));
    }

    /**
     * 新增非遗戏剧行当汇总
     */
//    @PreAuthorize("@ss.hasPermi('books:business:add')")
    @Log(title = "非遗戏剧行当汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BooksTheatreBusiness booksTheatreBusiness)
    {
        return toAjax(booksTheatreBusinessService.insertBooksTheatreBusiness(booksTheatreBusiness));
    }

    /**
     * 修改非遗戏剧行当汇总
     */
//    @PreAuthorize("@ss.hasPermi('books:business:edit')")
    @Log(title = "非遗戏剧行当汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BooksTheatreBusiness booksTheatreBusiness)
    {
        return toAjax(booksTheatreBusinessService.updateBooksTheatreBusiness(booksTheatreBusiness));
    }

    /**
     * 删除非遗戏剧行当汇总
     */
//    @PreAuthorize("@ss.hasPermi('books:business:remove')")
    @Log(title = "非遗戏剧行当汇总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{theatreBusinessIds}")
    public AjaxResult remove(@PathVariable Long[] theatreBusinessIds)
    {
        return toAjax(booksTheatreBusinessService.deleteBooksTheatreBusinessByTheatreBusinessIds(theatreBusinessIds));
    }
}
